<?php
/**
 * User: yuesir
 * Date: 2016/4/27
 * Time: 21:59
 */
namespace Lib\Database;
use Lib\IDatabase;

class MySQL implements IDatabase {
    protected $conn;
    /**
     * 连接数据库
     * @param $host
     * @param $user
     * @param $passwd
     * @param $dbname
     */
    function connect($host, $user, $passwd, $dbname)
    {
        $this->conn = mysql_connect($host, $user, $passwd);
        mysql_select_db($dbname);
    }

    /**
     * 查询数据库
     * @param $sql
     */
    function query($sql)
    {
        $res = mysql_query($sql, $this->conn);
        return $res;
    }

    /**
     * 关闭数据库
     */
    function close()
    {
        mysql_close($this->conn);
    }
}